// 过滤html标签
export function filterHtmlTags(html: string): string {
  if (!html) {
    return "";
  }
  const regex = /<[^>]+>/g;
  /**
   * 使用正则表达式替换所有匹配的标签
   * 过滤 &lt;等字符
   */

  html = html.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
  return html.replace(regex, "");
}

// 字符串截取
export function truncateString(str: string, maxLength: number): string {
  if (str.length <= maxLength) {
    return str;
  } else {
    return str.substring(0, maxLength) + "...";
  }
}

// 字符串转数组
export function stringToArray(str: string): string[] {
  if (!str) {
    return [];
  }
  return str.split(",");
}
